




/*
'===============================================================================
'  LinqHelper.DAO.HotelsBase
'===============================================================================
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using LinqHelper;
using LinqHelper.Entity;
using LinqHelper.DAO;

namespace LinqHelper.DAO
{
	public class LqHotelsBase
	{
		public LqProvider provider = new LqProvider();
		
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		public LqHotelsBase()
		{
			// Nothing for now.
		}
		
		public void Insert(LqHotelsEntity obj)
		{
			provider.GetTable<LqHotelsEntity>().InsertOnSubmit(obj);
            provider.SubmitChanges();
		}

		public void Update(LqHotelsEntity _obj)
		{
			var q = from obj in provider.GetTable<LqHotelsEntity>()
                    where obj.Id == _obj.Id
                    select obj;
			LqHotelsEntity tmp = q.First<LqHotelsEntity>();
			
			tmp.IntId = _obj.IntId;
			tmp.PhotoId = _obj.PhotoId;
			tmp.Price = _obj.Price;
			provider.SubmitChanges();
		}
		
		public void Delete(LqHotelsEntity obj)
		{
			provider.GetTable<LqHotelsEntity>().DeleteOnSubmit(obj);
            provider.SubmitChanges();
		}
		
		
		public void DeleteById(Guid Id)
		{
			var q = from obj in provider.GetTable<LqHotelsEntity>()
                    where obj.Id == Id
                    select obj;
					
            LqHotelsEntity ob = (LqHotelsEntity)q.First<LqHotelsEntity>();
            provider.GetTable<LqHotelsEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByIntId(string IntId)
		{
			var q = from obj in provider.GetTable<LqHotelsEntity>()
                    where obj.IntId == IntId
                    select obj;
					
            LqHotelsEntity ob = (LqHotelsEntity)q.First<LqHotelsEntity>();
            provider.GetTable<LqHotelsEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByPhotoId(Guid PhotoId)
		{
			var q = from obj in provider.GetTable<LqHotelsEntity>()
                    where obj.PhotoId.Value == PhotoId
                    select obj;
					
            LqHotelsEntity ob = (LqHotelsEntity)q.First<LqHotelsEntity>();
            provider.GetTable<LqHotelsEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public void DeleteByPrice(decimal Price)
		{
			var q = from obj in provider.GetTable<LqHotelsEntity>()
                    where obj.Price == Price
                    select obj;
					
            LqHotelsEntity ob = (LqHotelsEntity)q.First<LqHotelsEntity>();
            provider.GetTable<LqHotelsEntity>().DeleteOnSubmit(ob);
            provider.SubmitChanges();
		}
		
		
		public LqHotelsEntity SelectOne(Guid Id)
		{
			var query = from obj in provider.GetTable<LqHotelsEntity>()
                        where obj.Id == Id
                        select obj;
            return query.First<LqHotelsEntity>();
		}

		public List<LqHotelsEntity> SelectAll()
		{
			var query = from obj in provider.GetTable<LqHotelsEntity>()
                        select obj;
            return query.ToList<LqHotelsEntity>();
		}
		
		
		public List<LqHotelsEntity> SelectById(Guid Id)
		{
			var query = from obj in provider.GetTable<LqHotelsEntity>()
                        where obj.Id == Id
                        select obj;
            return query.ToList<LqHotelsEntity>();
		}
		
		
		public List<LqHotelsEntity> SelectByIntId(string IntId)
		{
			var query = from obj in provider.GetTable<LqHotelsEntity>()
                        where obj.IntId == IntId
                        select obj;
            return query.ToList<LqHotelsEntity>();
		}
		
		
		public List<LqHotelsEntity> SelectByPhotoId(Guid PhotoId)
		{
			var query = from obj in provider.GetTable<LqHotelsEntity>()
                        where obj.PhotoId.Value == PhotoId
                        select obj;
            return query.ToList<LqHotelsEntity>();
		}
		
		
		public List<LqHotelsEntity> SelectByPrice(decimal Price)
		{
			var query = from obj in provider.GetTable<LqHotelsEntity>()
                        where obj.Price == Price
                        select obj;
            return query.ToList<LqHotelsEntity>();
		}
		
		
		

	}
}
